package com.ticket.sass.provider.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.provider.business.FilmBusiness;
import com.ticket.sass.provider.business.impl.FilmBusinessImpl;
import com.ticket.sass.provider.dto.input.film.*;
import com.ticket.sass.provider.dto.output.film.FilmListOutput;
import com.ticket.sass.provider.dto.output.film.FilmQueryOutput;
import com.ticket.sass.provider.dto.output.film.FilmVersionOutput;
import com.ticket.sass.provider.model.ResultModel;
import com.ticket.sass.provider.service.PageModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author ywb
 * @date 2024-03-28 18:07
 */
@RestController
@ApiSupport(order = 6)
@RequestMapping("/films")
@Api(tags = {"影片-模块"})
public class FilmController {
    
    final FilmBusiness filmBusiness;
    
    public FilmController(FilmBusinessImpl filmBusiness) {
        this.filmBusiness = filmBusiness;
    }
    
    
    @GetMapping
    @ApiOperation("获取影片列表")
    public ResultModel<PageModel<FilmListOutput>> getFilmList(
        @Valid FilmListInput input) {
        PageModel<FilmListOutput> filmList = filmBusiness.list(input);
        return ResultModel.success(filmList);
    }
    
    @PostMapping
    @ApiOperation("新增影片")
    public ResultModel<String> addFilm(@RequestBody @Valid FilmAddInput input) {
        filmBusiness.add(input);
        return ResultModel.success();
    }
    
    @PutMapping
    @ApiOperation("更新影片")
    public ResultModel<String> updateFilm(@RequestBody @Valid FilmUpdInput input) {
        filmBusiness.upd(input);
        return ResultModel.success();
    }
    
    @GetMapping("/basic")
    @ApiOperation("影片基本数据查询")
    public ResultModel<FilmQueryOutput> queryData(@Valid FilmQueryInput input) {
        return ResultModel.success(
            filmBusiness.getFilmDetails(input)
        );
    }
    
    @GetMapping("/version")
    @ApiOperation("影片版本信息查询")
    public ResultModel<List<FilmVersionOutput>> queryVersion(@Valid FilmVersionQueryInput input) {
        return ResultModel.success(
            filmBusiness.getVersionDetails(input)
        );
    }
}
